﻿<UserControl x:Class="MultiTouch.Behaviors.Silverlight.Sample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:gestures="clr-namespace:MultiTouch.Behaviors.Silverlight.Gestures;assembly=MultiTouch.Behaviors.Silverlight"
    xmlns:silverlight="clr-namespace:MultiTouch.Behaviors.Silverlight;assembly=MultiTouch.Behaviors.Silverlight"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Canvas x:Name="LayoutRoot">
        <Canvas.Background>
            <ImageBrush ImageSource="Images/WindowBackground.jpg"/>
        </Canvas.Background>

        <!-- Behavior for this item is attached in code-behind-->
        <Canvas x:Name="item1">
            <Image Source="Images/Desert.jpg" Width="200"/>
            <Button Canvas.Top="6" Content="Attach Behavior via code-behind" Height="23" Name="btnAttach" Width="200" Click="btnAttach_Click"/>
            <Button Canvas.Top="35" Content="Detach Behavior via code-behind" Height="23" Name="btnDetach" Width="200" Click="btnDetach_Click"/>
        </Canvas>

        <Image x:Name="item2" Source="Images/Hydrangeas.jpg" Width="200">
            <i:Interaction.Behaviors>
                <gestures:DoubleTapBehavior DoubleTap="DoubleTapBehavior_DoubleTap"
                                            IsDefaultBehaviorEnabled="True" IsDoubleTapEventEnabled="True"/>
                <silverlight:MultiTouchBehavior IsRotateEnabled="True" IsScaleEnabled="True" 
                                              IsTranslateEnabled="True" 
                                              IsPivotEnabled="True" IsInertiaEnabled="True"
                                              MinimumScale="100" MaximumScale="500"
                                              AreManipulationsEnabled="True"
                                              IsConstrainedToParentBounds="False"/>
            </i:Interaction.Behaviors>     
        </Image>
        
        <Image x:Name="item3" Source="{Binding SelectedPicture}" Width="200">
            <i:Interaction.Behaviors>
                <silverlight:MultiTouchBehavior IsRotateEnabled="True" IsScaleEnabled="True" 
                                                IsTranslateEnabled="True" IsInertiaEnabled="True"
                                                MinimumScale="50" MaximumScale="360"
                                                AreFingersVisible="True"
                                               IsConstrainedToParentBounds="True"/>
            </i:Interaction.Behaviors>
        </Image>

        <!-- A list of available Images -->
        <ListBox x:Name="lstImages" Width="100" Canvas.Left="10" Canvas.Top="200"
                        ItemsSource="{Binding Pictures}" SelectedItem="{Binding SelectedPicture, Mode=TwoWay}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding}" Width="50"/>
                </DataTemplate>
            </ListBox.ItemTemplate>             
        </ListBox>
    </Canvas>
</UserControl>
